package cn.ycq.im.chat.handle;

import cn.ycq.im.chat.CmdHandler;
import cn.ycq.im.chat.CmdTransport;
import cn.ycq.im.chat.CmdType;
import cn.ycq.im.chat.MessageBuildUtils;
import cn.ycq.im.chat.clients.ChannelAttributeUtils;
import cn.ycq.im.chat.clients.ClientManager;
import com.alibaba.fastjson.JSON;
import io.netty.channel.ChannelHandlerContext;

public class ChatCmdHandler implements CmdHandler {

    @Override
    public CmdType getCmdType() {
        return CmdType.CHAT;
    }

    @Override
    public void handle(ChannelHandlerContext ctx, CmdTransport cmdTransport) {
        String userName = (String) ChannelAttributeUtils.getAttribute("userName", ctx.channel());
        ClientManager.writeAndFlush(userName,(String) cmdTransport.get("msg"));
    }
}
